package com.llkj.common.util;

import android.app.Activity;
import android.content.Context;
import android.view.Window;

import com.llkj.common.widget.dialog.LoadingDialog;

public class LoadDialogUtil {

    static LoadingDialog sLoadingDialog;

    public static LoadingDialog showLoading(Context context) {
        if (sLoadingDialog != null) {
            hideLoading();
        }
        sLoadingDialog = new LoadingDialog(context);
        sLoadingDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        if (context instanceof Activity && !((Activity) context).isFinishing()) {
            sLoadingDialog.show();
        }
        return sLoadingDialog;
    }

    public static void hideLoading() {
        if (sLoadingDialog != null && (sLoadingDialog.isShowing())) {
            sLoadingDialog.dismiss();
        }
        sLoadingDialog = null;
    }
}
